package com.zdsoft.blp.zongbuju.shouye.linliquan.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.zdsoft.blp.R;
import java.util.List;

/**
 * Created by Administrator on 2016/9/2.
 */
public class LinLiDialogAdapter extends BaseAdapter{
    private List<String> list;
    private LayoutInflater inflater;

    public LinLiDialogAdapter(List<String> list, Context context) {
        this.list = list;
        inflater = LayoutInflater.from(context);
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if(convertView == null){
            convertView = inflater.inflate(R.layout.linli_dialog_item,null);
            viewHolder = new ViewHolder();
            viewHolder.tv_ll_dialog = (TextView) convertView.findViewById(R.id.tv_ll_dialog);
            convertView.setTag(viewHolder);
        }else{
            viewHolder = (ViewHolder) convertView.getTag();
        }
        //给ViewHolder中的控件赋值
        viewHolder.tv_ll_dialog.setText(list.get(position));
        return convertView;
    }
    class ViewHolder{
        private TextView tv_ll_dialog;
    }
}
